package com.heima.controller;

import com.heima.utils.AliOSSUtils;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;

    /**
     * 图片上传
     * @param fileName
     * @return
     * @throws IOException
     */
    @PostMapping("/api/vm-service/sku/fileUpload")
    @ApiOperation("图片上传")
    public String upload(MultipartFile fileName) throws IOException {
        String pngUrl = aliOSSUtils.upload(fileName);
        return pngUrl;
    }

    //图片验证码
    @GetMapping("/api/user-service/user/imageCode/:clientToken")
    public String code(){
        return null;
    }
}
